---------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\utp-FigureA1_TabA2_A3.log
  log type:  text
 opened on:   2 Oct 2020, 10:31:29

.   
.   use "E:\ProjData\PlacementCandidacy\utp-DataMainSample.dta", clear

. 
.   local sample "inrange(InvAr, 1987, 1991) & inrange(InvAlder, 18, 55) & inrange(Ar, 1991, 2014) & FlyktInv == 1 & Rostratt == 1"

.   local controls1 "InvAr IFAUkod Ar FodelseAr"

.   local controls2 "Kvinna Gift_InvAr UtbAr_InvAr Barn0_15_InvAr"

.   local controls3 "LoneInk UtbAr Sysselsatt" 

.   listwise Alder Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald  InvAlder  InvAr TidI InvAlder logpEnklavVuxen
> InvAr

.   
.   reghdfe Nominerad logpEnklavVuxen `controls2' if `sample', absorb(KommunValAr `controls1') cluster(KommunValAr) old
(running historical version of reghdfe)
(converged in 9 iterations)

HDFE Linear regression                            Number of obs   =    349,383
Absorbing 5 HDFE groups                           F(   5,    324) =      10.38
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0160
                                                  Adj R-squared   =     0.0149
                                                  Within R-sq.    =     0.0014
Number of clusters (KommunValAr) =        325     Root MSE        =     7.5564

                             (Std. Err. adjusted for 325 clusters in KommunValAr)
---------------------------------------------------------------------------------
                |               Robust
      Nominerad |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
----------------+----------------------------------------------------------------
logpEnklavVuxen |  -.1148867   .0438747    -2.62   0.009     -.201202   -.0285714
         Kvinna |   -.185124   .0505866    -3.66   0.000    -.2846437   -.0856042
     Gift_InvAr |   .1726446   .0742474     2.33   0.021     .0265768    .3187124
    UtbAr_InvAr |   .0985908   .0160594     6.14   0.000      .066997    .1301846
 Barn0_15_InvAr |  -.0158587   .0215635    -0.74   0.463    -.0582809    .0265635
---------------------------------------------------------------------------------

Absorbed degrees of freedom:
------------------------------------------------------------------+
    Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     | 
----------------+-------------------------------------------------|
    KommunValAr |            0             325            325 *   | 
          InvAr |            4               5              1     | 
        IFAUkod |           15              16              1     | 
             Ar |            6               7              1 ?   | 
      FodelseAr |           41              42              1 ?   | 
------------------------------------------------------------------+
? = number of redundant parameters may be higher
* = fixed effect nested within cluster; treated as redundant for DoF computation

.   
.   keep if e(sample)==1
(0 observations deleted)

.   sum

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       LopNr |    349,383     6852306     4622538        548   1.61e+07
     Barn0_3 |    349,383    .1778392     .460376          0          5
     Barn4_6 |    349,383    .1532731    .4090913          0          4
    Barn7_10 |    349,383    .2280162    .5130267          0          5
   Barn11_15 |    349,383    .3052524    .6144781          0          5
-------------+---------------------------------------------------------
   Barn16_17 |    349,383    .1189755    .3447811          0          4
 Sun2000niva |    349,383    346.1672    181.0951        100        999
     LoneInk |    349,383    8.965646    12.53744          0     624.05
DispInkPersF |    190,616    794.0044    433.6946          0      20105
      ArbLos |    349,383    100.3907    252.3394          0       2835
-------------+---------------------------------------------------------
  SocBidrFam |    349,383    136.5355    319.6775          0       8119
 BostBidrFam |    349,383    61.76551    116.0806          0       1032
   SyssStatG |     19,081    3.144227    2.303005          1          6
          Ar |    349,383     2003.04    7.207145       1991       2014
  Sysselsatt |    349,383    .5143925    .4997935          0          1
-------------+---------------------------------------------------------
   ArbetsLos |    349,383    .2163586    .4117621          0          1
   Socbidrag |    349,383    .2730471    .4455255          0          1
       UtbAr |    339,845    11.28994    2.856433          7         19
  Forsamling |    349,383    91969.07    67887.71      11401     258402
      sCivil |          0
-------------+---------------------------------------------------------
Medblandnamn |          0
     IFAUkod |    349,383    43.10775    4.958862         30         51
Antal_FLxKom |    349,383    3068.556    3976.351          2      18734
 Storlek_Kom |    349,383      252342    272295.5       2451     911944
Antal_FLxK~n |    349,383    2770.316    3658.227          1      18313
-------------+---------------------------------------------------------
Storlek_Ko~n |    349,383    203148.1    221639.7       1991     733680
    SyssStat |    171,535    3.655371    2.377294          1          6
DispInkPe~04 |    158,767    1516.296    1316.432     -22811     176537
   SyssStatJ |    107,205    2.965981    2.387718          1          6
  SyssStat11 |     51,562    2.991505    2.402112          1          6
-------------+---------------------------------------------------------
    InvDatum |          0
       InvAr |    349,383    1988.955    1.357491       1987       1991
    InKommun |    349,383    1149.721    751.3616        114       2584
InForsamling |    349,383    114979.5    75132.91      11401     258402
sCivil_InvAr |          0
-------------+---------------------------------------------------------
    FlyktInv |    349,383           1           0          1          1
    DodDatum |     10,575    2.01e+07    49452.68   1.99e+07   2.02e+07
    FodArMan |    349,383    195857.8    820.2783     193201     197312
   UtlSvBakG |    349,383          11           0         11         11
         Kon |    349,383    .5816454    .4932897          0          1
-------------+---------------------------------------------------------
Anta~m_InvAr |    349,383    741.9432    1279.207          2       6715
Anta~n_InvAr |    349,383     613.833    1110.886          2       6370
Stor~m_InvAr |    349,383    137886.1      199088       2959     679278
Stor~n_InvAr |    349,383    112046.2    165798.9       2367     562293
     AterPnr |      2,037           0           0          0          0
-------------+---------------------------------------------------------
      SenPnr |      2,037    .9955817    .0663393          0          1
 valkretskod |      1,731    1.634315    1.854462          0         16
    Partikod |      2,037     46.4433    135.8293          1       1261
      nrinom |      1,917    17.16641    13.06683          1         73
      valtyp |          0
-------------+---------------------------------------------------------
       valar |      2,037    2005.481    6.370152       1991       2014
    election |          0
        llkk |      1,596    1152.719    756.4084        114       2584
          ll |      1,532    10.72324    7.473299          1         25
      listnr |      1,917    3101.124    2465.494          4      11465
-------------+---------------------------------------------------------
  kommunnamn |          0
   partinamn |          0
          lk |        347    10.05476    7.949254          1         25
       Parti |          0
        vald |      1,973    .0775469     .267525          0          1
-------------+---------------------------------------------------------
 mandatparti |      1,973    .8915357    .3110447          0          1
    Lansnamn |          0
  Kommunnamn |          0
Valkretsnamn |          0
  Ripartikod |      1,973    940.1069    2896.685          1       9997
-------------+---------------------------------------------------------
      ltnamn |          0
kommunvalk~s |        208    1.254808    1.409929          0          6
antpersonr~t |      1,853    22.91959    65.03685          0       1123
    lansnamn |          0
  pnamn_kort |          0
-------------+---------------------------------------------------------
riksdagsva~s |         12       20.75    9.176303          5         29
 ejpers_vald |        714    .1596639    .3665508          0          1
        Vald |    349,383    .0998904    3.158969          0        100
   Nominerad |    349,383    .5830278    7.613345          0        100
         occ |      2,037           1           0          1          1
-------------+---------------------------------------------------------
 maxPersRost |      1,853    22.91959    65.03685          0       1123
   minListNr |      1,917    17.16641    13.06683          1         73
   UtbInfoAr |    349,383    1991.399    2.588145       1990       2013
 UtbAr_InvAr |    349,383    10.80342    2.726398          7         19
      ValDag |          0
-------------+---------------------------------------------------------
     nValDag |    349,383    2.00e+07    72071.45   1.99e+07   2.01e+07
   tFodArMan |    349,383   -382.5199    2997.341     -10227       5083
   tInvDatum |    349,383    10747.02    509.2298       9862      11679
     tValDag |    349,383    15977.82    2632.433      11580      19981
 TidISverige |    349,383    14.32117    7.151052    3.00616   27.69336
-------------+---------------------------------------------------------
 AlderValDag |    349,383    44.79218    10.78327    20.7885   82.70499
    Rostratt |    349,383           1           0          1          1
    Barn0_15 |    349,383    .8643809    1.210051          0         12
        Gift |    349,381    .5796137    .4936217          0          1
   SvMedborg |    349,383    .6579427    .4743993          0          1
-------------+---------------------------------------------------------
   sInKommun |          0
     sKommun |          0
 KommunValAr |    349,383    921.7422    681.4515        114       2584
   FodelseAr |    349,383    1958.515    8.202929       1932       1973
    InvAlder |    349,383    30.44009    8.114223         18         55
-------------+---------------------------------------------------------
   logEnklav |    349,383    6.893217    1.793677          0   9.838042
logEnklavI~r |    349,383    5.237851    1.750777          0    8.81195
     pEnklav |    349,383    .0110442    .0099782   .0000271   .0907205
pEnklavInvAr |    349,383    .0048761    .0049022   .0000176   .0433633
  logpEnklav |    349,383   -4.861727    .9037362  -10.51648  -2.399972
-------------+---------------------------------------------------------
logpE~vInvAr |    349,383   -5.726149    .9492465  -10.94796  -3.138142
logEnklavV~n |    349,355    6.752339    1.832896          0   9.815312
logEnklavV~r |    349,383    4.922589    1.840405          0   8.759198
pEnklavVuxen |    349,383    .0139675    .0126822   .0000348   .1141087
pEnklavVux~r |    349,383     .004792    .0053431   .0000218   .0515211
-------------+---------------------------------------------------------
logpEnklav~n |    349,383   -4.625358    .8995117  -10.26486  -2.170603
logpE~nInvAr |    349,383   -5.797845    1.006142  -10.73263  -2.965763
 forstaInvAr |     30,090    1985.897    30.83752          0       1991
      AntInv |    349,383    1.102664    .3641998          1          7
 sForsamling |          0
-------------+---------------------------------------------------------
   KommunKod |    349,383    919.5739    678.9047        114       2584
       ValAr |    349,383     2003.04    7.207145       1991       2014
  KommunNamn |          0
   KMStorlek |    349,383    69.32335    18.27198         21        101
     Rostber |    349,383    198783.6    216571.5       1968     715542
-------------+---------------------------------------------------------
      RMKvot |    349,383    .0011073    .0011556   .0001412    .015752
  Gift_InvAr |    349,383    .5852174    .4926852          0          1
   LopNrBarn |    299,419     7005891     4697086        540   1.61e+07
   FodArBarn |    299,419    1990.082    10.20811       1951       2015
       rBarn |    299,419   -1.116643    10.14586        -28         37
-------------+---------------------------------------------------------
       D0_15 |    299,419    .4286635    .4948858          0          1
Barn0_15_I~r |    349,383    1.034126    1.321485          0         11
     FamTypF |    349,383    27.41592    17.32275         11         50
      AntArb |    163,063    500.0278    1399.997          1      11688
AntArbInfodd |    163,063    396.4517    1144.739          0       9434
-------------+---------------------------------------------------------
 AntArbFland |    163,063    8.936816    22.80088          1        493
   PartFland |    200,952    39.42379    12.67498          0         52
  PartSvensk |    349,383    .0459238    .2093202          0          1
ArbAndSvensk |    349,383    .2788956    .3684962          0   .9950063
      _merge |    349,383           3           0          3          3
-------------+---------------------------------------------------------
      Kvinna |    349,383    .4183546    .4932897          0          1
      sample |    349,383           1           0          1          1
     cEnklav |    349,383    .4999413    .5000007          0          1
     _est_c1 |    349,383           1           0          1          1
    _est_c1b |    349,383           1           0          1          1
-------------+---------------------------------------------------------
 EnklavInvAr |    349,383    .4999642    .5000007          0          1
      Enklav |    349,383    .4990483    .4999998          0          1

.   
.         gen Mover = KommunValAr != InKommun if KommunValAr<. & InKommun<.

.         
.         di "************************Movers and Stayers in 1991*********************************"
************************Movers and Stayers in 1991*********************************

.         tab Mover if Ar==1991 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     11,852       62.11       62.11
          1 |      7,229       37.89      100.00
------------+-----------------------------------
      Total |     19,081      100.00

.         
.         di "************************Movers and Stayers in 1994*********************************"
************************Movers and Stayers in 1994*********************************

.         tab Mover if Ar==1994 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     31,393       55.67       55.67
          1 |     25,002       44.33      100.00
------------+-----------------------------------
      Total |     56,395      100.00

.         
.         di "************************Movers and Stayers in 1998*********************************"
************************Movers and Stayers in 1998*********************************

.         tab Mover if Ar==1998 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     25,722       43.95       43.95
          1 |     32,803       56.05      100.00
------------+-----------------------------------
      Total |     58,525      100.00

. 
.         di "************************Movers and Stayers in 2002*********************************"
************************Movers and Stayers in 2002*********************************

.         tab Mover if Ar==2002 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     24,366       43.04       43.04
          1 |     32,249       56.96      100.00
------------+-----------------------------------
      Total |     56,615      100.00

.         
.         di "************************Movers and Stayers in 2006*********************************"
************************Movers and Stayers in 2006*********************************

.         tab Mover if Ar==2006 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     22,240       40.83       40.83
          1 |     32,234       59.17      100.00
------------+-----------------------------------
      Total |     54,474      100.00

.         
.         di "************************Movers and Stayers in 2010*********************************"
************************Movers and Stayers in 2010*********************************

.         tab Mover if Ar==2010 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     20,757       39.36       39.36
          1 |     31,974       60.64      100.00
------------+-----------------------------------
      Total |     52,731      100.00

.         
.         di "************************Movers and Stayers in 2014*********************************"
************************Movers and Stayers in 2014*********************************

.         tab Mover if Ar==2014 

      Mover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     19,683       38.17       38.17
          1 |     31,879       61.83      100.00
------------+-----------------------------------
      Total |     51,562      100.00

.         
.         bysort LopNr: egen mMover = max(Mover)

.     
.         bysort Ar: egen AndFlytt = mean(Mover)

.         bysort Ar: gen id = _n

.         gen AndKvar = 1-AndFlytt

.         
.         twoway (scatter AndKvar Ar if id == 1, color(black) ylabels(.2(.1).8) yscale(range(0.2 .8)) ytitle("Share Stayers") xtitle("Year"))
>  ///
>                (line AndKvar Ar if id == 1, lcolor(black)), legend(off) graphregion(color(white))

.         graph export "`output'\Output\FigureA1.png", replace
(note: file C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\FigureA1.png not found)
(file C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\FigureA1.png written in PNG format)

.         tab mMover 

     mMover |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    116,723       33.41       33.41
          1 |    232,660       66.59      100.00
------------+-----------------------------------
      Total |    349,383      100.00

.         
. di "Descriptive statistics in 2014 for all in the sample"
Descriptive statistics in 2014 for all in the sample

.   estpost tabstat Alder Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald  InvAlder  InvAr if Ar ==2014 , column(
> stat) statistics(mean sd)

Summary statistics: mean sd
     for variables: AlderValDag Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald InvAlder InvAr

             |   e(mean)      e(sd) 
-------------+----------------------
 AlderValDag |  55.51335   8.013617 
      Kvinna |  .4275048   .4947213 
  Gift_InvAr |   .590493   .4917476 
Barn0_15_I~r |  1.067821   1.336688 
 UtbAr_InvAr |  10.78669   2.728672 
logpE~vInvAr | -5.717388   .9474954 
   Nominerad |  .7757651   8.773608 
        Vald |  .1861836   4.310923 
    InvAlder |  30.31389   7.927077 
       InvAr |  1989.068   1.351471 

.   eststo md1

. 
. di "Descriptive statistics in 2014 for those who never moved"
Descriptive statistics in 2014 for those who never moved

.   estpost tabstat Alder Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald  InvAlder  InvAr if Ar ==2014 & Mover==
> 0, column(stat) statistics(mean sd)

Summary statistics: mean sd
     for variables: AlderValDag Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald InvAlder InvAr

             |   e(mean)      e(sd) 
-------------+----------------------
 AlderValDag |  56.57985   8.480826 
      Kvinna |  .4790428   .4995733 
  Gift_InvAr |  .6107809   .4875856 
Barn0_15_I~r |  1.095412   1.308303 
 UtbAr_InvAr |  10.58853   2.767605 
logpE~vInvAr | -5.495026   .9017536 
   Nominerad |  .8027232   8.923676 
        Vald |  .1828989   4.272864 
    InvAlder |  31.35894   8.364162 
       InvAr |  1989.046   1.350623 

.   eststo md2

. 
. di "Descriptive statistics in 2014 for those who moved before 2014"     
Descriptive statistics in 2014 for those who moved before 2014

.   estpost tabstat Alder Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald  InvAlder  InvAr if Ar ==2014 & Mover==
> 1, column(stat) statistics(mean sd)

Summary statistics: mean sd
     for variables: AlderValDag Kvinna Gift_InvAr Barn0_15_InvAr UtbAr_InvAr logpEnklavInvAr Nominerad Vald InvAlder InvAr

             |   e(mean)      e(sd) 
-------------+----------------------
 AlderValDag |  54.85487   7.637155 
      Kvinna |  .3956837   .4890047 
  Gift_InvAr |  .5779667   .4938915 
Barn0_15_I~r |  1.050786   1.353656 
 UtbAr_InvAr |  10.90905   2.697137 
logpE~vInvAr |  -5.85468   .9490115 
   Nominerad |  .7591204   8.679755 
        Vald |  .1882117    4.33432 
    InvAlder |  29.66865   7.573205 
       InvAr |  1989.081   1.351842 

.   eststo md3

. 
.   esttab md1 md2 md3 using "`output'\Output\TableA3.rtf", main(mean) aux(sd) nostar unstack nonote nomtitle b(2) ///
>                                 rename(Alder Age Kvinna Female Gift_InvAr Married Barn0_15_InvAr "Nr of children under 16" ///
>                                  UtbAr_InvAr "Years of education" Nominerad Nominated(%) Vald Elected(%) ///
>                                 InvAlder "Age at immigration" InvAr "Immigration year" logpEnklavInvAr "Ethnic density (log)") replace
(note: file C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\TableA3.rtf not found)
(output written to C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\TableA3.rtf)

.                                 
. // Tabulate the frequencies for country of birth in the sample
.   eststo clear  

.  
.   capture drop id

.   gsort LopNr -Ar

.   bysort LopNr: gen id = _n

.   
.   codebook LopNr, compact

Variable      Obs Unique     Mean  Min       Max  Label
---------------------------------------------------------------------------------------------------------------------------------------------
LopNr      349383  62230  6852306  548  1.61e+07  Serial number replacing personal number
---------------------------------------------------------------------------------------------------------------------------------------------

.   estpost tabulate IFAUkod if id==1

     IFAUkod |      e(b)     e(pct)  e(cumpct) 
-------------+---------------------------------
          30 |      2453   3.941829   3.941829 
          31 |      2014   3.236381    7.17821 
          35 |       192   .3085329   7.486743 
          36 |      4175   6.708983   14.19573 
          37 |      1431   2.299534   16.49526 
          40 |       959   1.541057   18.03632 
          41 |      6326   10.16552   28.20183 
          42 |      1605   2.579142   30.78097 
          43 |      6475   10.40495   41.18592 
          44 |      9296   14.93813   56.12406 
          45 |      1325   2.129198   58.25325 
          46 |     15241    24.4914   82.74466 
          47 |      4222   6.784509   89.52917 
          48 |      2044   3.284589   92.81376 
          50 |      2805   4.507472   97.32123 
          51 |      1667   2.678772        100 
-------------+---------------------------------
       Total |     62230        100            

.   esttab using "`output'\Output\TableA2.rtf", cells("b(label(freq)) pct(fmt(2))") replace
(note: file C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\TableA2.rtf not found)
(output written to C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\TableA2.rtf)

. 
. log close
      name:  <unnamed>
       log:  C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output\utp-FigureA1_TabA2_A3.log
  log type:  text
 closed on:   2 Oct 2020, 10:31:51
---------------------------------------------------------------------------------------------------------------------------------------------
